feat(bootstrapper): record bootstrap stack state on each loop iteration#1159
feat(bootstrapper): record bootstrap stack state on each loop iteration#1159dhellmann wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe PR adds persistent stack recording to the bootstrap resolver. Bootstrapper now sets a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fromager/bootstrapper.py`:
- Around line 1305-1307: The current bootstrap() snapshot write using
open(self._stack_filename, "w") may truncate the file and abort bootstrap on
error; instead, serialize the reversed(stack) into records and write JSON
atomically by writing to a temporary file in the same directory (e.g., use
tempfile.NamedTemporaryFile or a .tmp path) and then atomically replace the
target with os.replace; catch and log any exceptions (use the existing logger on
the object, e.g., self._logger or fallback logger) as a non-fatal warning so
bootstrap() continues on failure, referencing the existing serialize() call and
self._stack_filename to locate the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 876da36e-8403-4513-abee-eb324d8b2989
📒 Files selected for processing (2)
src/fromager/bootstrapper.pytests/test_bootstrapper.py
|
|
||
| # Main iterative DFS loop | ||
| while stack: | ||
| self._record_stack_state(stack) |
There was a problem hiding this comment.
Rather than directly calling it , should we call it from a try/exception block. The idea is to write exceptions that escape the loop. Because it would be efficient writing when required as compared to writing the entire stack as JSON to disk on every iteration of the DFS loop
try:
while stack:
item = stack.pop()
self.why = list(item.why_snapshot)
with req_ctxvar_context(item.req), self._track_why(item):
try:
new_items = self._dispatch_phase(item)
except Exception as err:
new_items = self._handle_phase_error(item, err)
# ... rest of loop ...
except Exception:
self._record_stack_state(stack)
raise
There was a problem hiding this comment.
It takes a lot less time to write than you might think, and having it available as work is progressing gives you the option of watching what the tool is doing as it works.
Write `bootstrap-stack.json` to the work directory before each iteration of the DFS loop, capturing the full stack as a JSON array (index 0 = next item to pop). Enables debugging, progress inspection, and post-mortem analysis of interrupted runs. Co-Authored-By: Claude <claude@anthropic.com> Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
Log the path of the bootstrap stack JSON file once when `Bootstrapper` is initialized, so users know where to find it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Doug Hellmann <dhellmann@redhat.com>
27e56a7 to
0abe106
Compare
Summary
Writes
bootstrap-stack.jsonto the work directory before each iteration of the DFS loop inBootstrapper.bootstrap(). The file is a JSON array where index 0 is the next item to be processed (stack[-1]), overwritten on each iteration. Each entry captures identity and accumulated state fields (req,req_type,phase,resolved_version,source_url,why,parent, dep sets); heavy build objects (build_env, paths,build_result) are intentionally excluded.Enables debugging, progress inspection, and post-mortem analysis of interrupted runs.
🤖 Generated with Claude Code